package com.machine.filling.function.main.error;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.machine.filling.R;
import com.machine.filling.base.baseMvp.BaseFragment;
import com.machine.filling.function.init.INextFragment;
import com.machine.filling.util.CustomToast;
import com.machine.filling.util.StringUtil;

/**
 * Created by Administrator on 2018/4/13 0013.
 *
 * @description
 */
public class ErrorFragment extends BaseFragment<ErrorContract.Presenter> implements ErrorContract.View, View.OnClickListener {
    public ErrorFragment() {
    }

    private INextFragment INextFragment;
    private TextView tv_text;
    private ImageView iv_back;
    private String className;
    private String noticeStr;

    public ErrorFragment(String noticeStr,String className) {
        this.noticeStr = noticeStr;
        this.className = className;
    }

    @Override
    public View initViews() {
        View view = LayoutInflater.from(mActivity).inflate(R.layout.fg_fg_error, null);
        tv_text = view.findViewById(R.id.tv_text);
        iv_back = view.findViewById(R.id.iv_back);
        iv_back.setOnClickListener(this);
        iv_back.setVisibility(View.GONE);
        return view;
    }

    @Override
    public void initDatas() {
        tv_text.setText(noticeStr);
    }

    public void setINextFragment(INextFragment INextFragment) {
        this.INextFragment = INextFragment;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_back:
                if (!StringUtil.isNullOrEmpty(className)) {
                    INextFragment.replaceNext(new Intent(), className);
                }else {
                    CustomToast.showToast( mContext,"无效");
                }
                break;
        }
    }
}
